/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package SessionBeans;
//modif dorra

import Entities.Marquage;
import Entities.Modelerdp;
import java.util.Collection;
import java.util.List;
import javax.ejb.Stateless;
import javax.ejb.LocalBean;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author Dell
 */
@Stateless
@LocalBean
public class MarquageManager {
    @PersistenceContext(unitName = "PetriNetSimulator-ejbPU")
    private EntityManager em;

   public void persist(Object object) {
        em.persist(object);
    }
    public List<Marquage> getAllRdpMarquages() {
        Query query = em.createNamedQuery("Marquage.findAll");
        return query.getResultList();
    }
    public List<Marquage> findByIdmodule(Modelerdp m)
    {

        Query query = em.createNamedQuery("Marquage.findByIdm");
        query.setParameter("idm", m);
        return query.getResultList();
        
        
    }
   
    public Marquage savemarking(Modelerdp idm, int refmarq, String VectMarq)
    {
        Marquage marquage = new Marquage();
        marquage.setIdm(idm);
        marquage.setRefmarquage(refmarq);
        marquage.setVecteurMarquage(VectMarq);
        em.persist(marquage);
        return marquage;
    }

    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")
    public Marquage update(Marquage marquage) {
        return em.merge(marquage);
    }
}
